<nav class="navbar-default navbar-static-side" role="navigation"> {% load static %}
    <div class="sidebar-collapse">
        <ul class="nav" id="side-menu">
            {% include 'nav_li_profile.html' %}
            <li class="default">
                <a href="/"><i class="fa fa-th-large"></i> <span class="nav-label">仪表盘</span><span
                        class="label label-info pull-right"></span></a>

            </li>

            <li class="assets">
                <a href="#"><i class="fa fa-rebel"></i> <span class="nav-label">资产管理</span><span
                        class="fa arrow"></span></a>
                <ul class="nav nav-second-level">
                    <li class="server host_list host_add host_add_batch ip_list zabbix">
                        <a href="#">服务器管理 <span class="fa arrow"></span></a>
                        <ul class="nav nav-third-level">
                            {% if request.user.is_superuser or request.session.fun_auth.select_host %}
                                <li class="host_list"><a href="{% url 'host_list' %}">服务器列表</a></li>
                            {% endif %}

                            {% if request.user.is_superuser or request.session.fun_auth.bat_add_host %}
                                <li class="host_add_batch"><a href="/assets/host_add_batch/">批量添加主机</a></li>
                                <li class="ip_list"><a href="/assets/ip_list/">IP列表</a></li>
                                <li class="zabbix"><a href="/assets/zabbix/">zabbix信息</a></li>
                            {% endif %}
                        </ul>
                    </li>
                    <li class="room idc_add idc_list">
                        <a href="#">机房管理 <span class="fa arrow"></span></a>
                        <ul class="nav nav-third-level">
                            {% if request.user.is_superuser or request.session.fun_auth.select_idc %}
                                <li class="idcs"><a href="{% url 'idc_list' %}">机房列表</a></li>
                            {% endif %}

                        </ul>
                    </li>
                    <li class="salt">
                        <a href="#">系统管理<span class="fa arrow"></span></a>
                        <ul class="nav nav-third-level">
                            {% if request.user.is_superuser or request.session.fun_auth.setup_system %}
                                <li><a href="/salt/install/">安装系统</a></li>
                            {% endif %}
                            {% if request.user.is_superuser or request.session.fun_auth.upload_system %}
                                <li><a href="/salt/status/">主机上报</a></li>
                            {% endif %}
                            {% if request.user.is_superuser or request.session.fun_auth.salt_keys %}
                                <li><a href="/salt/key_list/">Salt认证管理</a></li>
                            {% endif %}
                        </ul>
                    </li>
                    <li class="project service_add service_list">
                        <a href="#">项目管理<span class="fa arrow"></span></a>
                        <ul class="nav nav-third-level">
                            {% if request.user.is_superuser or request.session.fun_auth.project_auth %}
                                <li><a href="{% url 'project_list' %}">项目列表</a></li>
                            {% endif %}
                            {% if request.user.is_superuser or request.session.fun_auth.add_project %}
                                <li class="service_list"><a href="{% url 'services_list' %}">服务列表</a></li>
                            {% endif %}
                            {% if request.user.is_superuser or request.session.fun_auth.add_line_auth %}
                                <li><a href="{% url 'product_lines_list' %}">产品线列表</a></li>
                            {% endif %}
                            {% if request.user.is_superuser %}
                                <li><a href="{% url 'code_rep_list' %}"> 代码仓库列表</a></li>
                            {% endif %}
                            <li><a href="/assets/server/host_without_business/"> 未分配项目主机</a></li>
                        </ul>
                    </li>
                </ul>
            </li>
            {% if request.user.username %}
                <li class="swan auto">
                    <a href="###"><i class="fa fa-cube"></i> <span class="nav-label">自动化运维</span><span
                            class="fa arrow"></span></a>
                    <ul class="nav nav-second-level">

                        <li><a href="/swan/apply/{{ request.user.pk }}/">发布申请</a></li>
                    </ul>
                </li>

                <li class="monitor">
                    <a href="###"><i class="fa fa-cube"></i> <span class="nav-label">业务监控</span><span
                            class="fa arrow"></span></a>
                    <ul class="nav nav-second-level">
                        <li class="http">
                            <a href="#">http类型监控<span class="fa arrow"></span></a>
                            <ul class="nav nav-third-level">
                                <li><a href="/monitor/http/add/">添加监控</a></li>
                                <li><a href="/monitor/http/list/">监控列表</a></li>
                            </ul>
                        </li>
                        <li class="mysql">
                            <a href="#">数据库监控<span class="fa arrow"></span></a>
                            <ul class="nav nav-third-level">
                                <li><a href="/monitor/http/add/">添加监控</a></li>
                                <li><a href="/monitor/http/list/">监控列表</a></li>
                            </ul>
                        </li>
                    </ul>
                </li>
                <li class="incident">
                    <a href="###"><i class="fa fa-bomb"></i> <span class="nav-label">故障管理</span><span
                            class="fa arrow"></span></a>
                    <ul class="nav nav-second-level">
                        <li><a href="{% url 'malfunction_create' %}">添加故障</a></li>
                        <li><a href="{% url 'malfunction_unhandled' %}">待处理故障</a></li>
                        <li><a href="{% url 'malfunction_done' %}">已处理故障</a></li>
                        <li><a href="{% url 'malfunction_my' %}">我的故障</a></li>
                        <li><a href="{% url 'malfunction_classical' %}">精典案例</a></li>
                    </ul>
                </li>
            {% endif %}
            {% if request.user.is_superuser or request.session.fun_auth.add_user or request.session.fun_auth.edit_user or request.session.fun_auth.add_department %}
                <li class="accounts">
                    <a href="#"><i class="fa fa-user"></i> <span class="nav-label">用户管理</span><span
                            class="fa arrow"></span></a>
                    <ul class="nav nav-second-level">
                        {% if request.user.is_superuser or request.session.fun_auth.add_user %}
                            <li><a href="{% url 'user_list' %}">用户列表</a></li>
                        {% endif %}

                        {% if request.user.is_superuser or request.session.fun_auth.add_department %}
                            <li><a href="{% url 'department_list' %}">部门列表</a></li>
                        {% endif %}
                        <li><a href="{% url 'user_info' %}">用戶信息</a></li>

                    </ul>
                </li>
            {% endif %}
            {% if request.user.is_superuser or request.session.fun_auth.cmdb_log or request.session.fun_auth.auth_log or request.session.fun_auth.server_audit %}
                <li class="logs">
                    <a href="#"><i class="glyphicon glyphicon-eye-open"></i> <span class="nav-label">日志审计</span><span
                            class="fa arrow"></span></a>
                    <ul class="nav nav-second-level">
                        {#                    {% if request.user.is_superuser or request.session.fun_auth.cmdb_log %}#}
                        {#                    <li><a href="/logs/idc/"><i class="glyphicon glyphicon-eye-open"></i>资产操作日志</a></li>#}
                        {#                    {% endif %}#}
                        {#                    {% if request.user.is_superuser or request.session.fun_auth.auth_log %}#}
                        {#                    <li><a href="/logs/salt/"><i class="fa fa-files-o"></i>自动化操作记录</a></li>#}
                        {#                    {% endif %}#}
                        {% if request.user.is_superuser or request.session.fun_auth.server_audit %}
                            <li><a href="/logs/host/"><i class="glyphicon glyphicon-tint"></i>服务器操作记录</a></li>
                        {% endif %}
                    </ul>
                </li>
            {% endif %}

            {% if request.user.is_superuser %}
                <li class="auth">
                    <a href="#"><i class="glyphicon glyphicon-briefcase"></i> <span class="nav-label">权限系统</span><span
                            class="fa arrow"></span></a>
                    <ul class="nav nav-second-level">
                        <li><a href="{% url 'auth_list' %}"><i class="glyphicon glyphicon-user"></i>角色列表</a></li>
                        <li><a href="{% url 'push_permission_list' %}"><i class="fa fa-bar-chart-o"></i> 发布权限 </a></li>
                        <li><a href="{% url 'host_user_manager_count_list' %}"><i class="fa fa-linux"></i> 服务器授权 </a></li>
                    </ul>
                </li>
            {% endif %}
            <li class="landing_link">
                <a href="/ops/doc/"><i class="fa fa-star"></i> <span class="nav-label">运维规范</span> <span
                        class="label label-warning pull-right">NEW</span></a>
            </li>
        </ul>

    </div>
</nav>
<!-- 右侧菜单栏控制 -->
<script type="text/javascript">
    var str = document.location.pathname.split("/")[1];
    var two = document.location.pathname.split("/")[2];
    var three = document.location.pathname.split("/")[3];

    if (str == "swan") {
        $("." + str).addClass('active');
    }

    if (str == "salt") {
        $(".assets").addClass('active');
        $("." + str).addClass('active');
    }
    else if (str == "assets" && three == "room") {
        $("." + str).addClass('active');
        $("." + three).addClass('active');
    }
    else if (str == "assets" && two == "server" && three == "type") {
        $("." + str).addClass('active');
        $(".project").addClass('active');
    }
    else if (str == "assets" && two == "server" && three == "host_without_business") {
        $("." + str).addClass('active');
        $(".project").addClass('active');
    }
    else if (str == "assets" && two == "product") {
        $("." + str).addClass('active');
        $(".project").addClass('active');
    }
    else if (str == "assets" && two == "server") {
        $("." + str).addClass('active');
        $("." + two).addClass('active');
    }
    else if (str == "conf" && two == "server") {
        $("." + str).addClass('active');
        $("." + two).addClass('active');
    }
    else if (two == "install" || two == "project" && three == "add") {
        $(".assets").addClass('active');
        $("." + str).addClass('active');
        $("." + two).addClass('active');
    }
    else {
        try {
            $("." + str).addClass('active');
            $("." + two).addClass('active');
        }
        catch (err) {

        }
    }

</script>
